<?php
/**
 * @author Amissah Gideon<kuulmek@yahoo.com>
 * @access public
 * @version 1.0
 */
$tenor_opts = array();
for($x = 1; $x <= 500; $x++){
    $tenor_opts[$x] = $x;
}

$months_opts = array();
for($x = 1; $x <= 500; $x++){
    $months_opts[$x] = $x;
}

$decimal_places_opts = array();
for ($x = 1; $x <= 20; $x++) {
    $decimal_places_opts[$x] = $x;
}

$purchase_type_opt = array("Interest Payment"=>"Interest Payment","Non Interest Payment"=>"Non Interest Payment","Outright Payment"=>"Outright Payment");

?>
<script type="text/javascript">
    var gbl_customers_sales = <?php echo json_encode($customers_sales); ?>;
    //console.log(global_equipment_data);
</script>


<!-- Main content -->
<section role="main" id="main">

    <!-- Header -->
    <?php
        echo $this->element('page_header');
        echo $this->element('navigations/editsale_navbar');
    ?>

    <div class="with-padding">
        <div class="columns">
            <div class="new-row-mobile twelve-columns six-columns-tablet twelve-columns-mobile">

                <h3 class="thin underline">Modify Sales and Reprint Invoices</h3>

                <table id="flex" style="display:none;"></table>

                <div style="display: none;">
                    <div id="form-window" style="margin: 20px 5px 5px 5px;">
                        <div class="prompt" ></div>
                        <?php echo $this->Form->create('Sale', array('default' => false, 'id' => 'form', 'action' => 'add','inputDefaults' => array('label' => false,'div' => false)));?>
                        <fieldset class="fieldset">
                            <legend class="legend">Info</legend>

                            <p class="button-height inline-label">
                                <label class="label">Vehicle No.:</label>
                                <?php echo $this->Form->input('vehicle_no', array('type' => 'text','id'=>'vehicle_no', 'class' => 'input', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Purchase Date:</label>
                                <span class="input">
                                    <?php echo $this->Form->input('purchased_date', array('type'=>'text','id'=>'purchased_date', 'class' => 'input-unstyled validate[required]',  'readonly' => 'readonly','div' => false, 'label' => false,)); ?>
                                    <a href="javascript:void(0)" class="button compact" id="purchased_date_btn">Date</a>
                                </span>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Transaction Currency:</label>
                                <?php echo $this->Form->input('currency', array('id'=>'currency', 'class' => 'select' ,'options'=>$currency_opts,'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Purchase Type:</label>
                                <?php echo $this->Form->input('purchase_type', array( 'div' => false, 'label' => false, 'id' => 'purchase_type', 'class' => 'select blue-gradient', 'options' => $purchase_type_opt));  ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Total Items Cost:</label>
                                <?php echo $this->Form->input('cost', array('type' => 'text','id'=>'cost', 'class' => 'input validate[required,custom[number]] ', 'value'=>'0.00', 'readonly' => 'readonly','div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Insurance Total:</label>
                                <?php echo $this->Form->input('insurance_total', array('type' => 'text','id'=>'insurance_total', 'class' => 'input validate[required,custom[number]] ', 'value'=>'0.00' ,'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Interest % per Anum:</label>
                                <?php echo $this->Form->input('interest', array('type' => 'text','id'=>'interest', 'class' => 'input validate[required,custom[number]]' ,'value'=>'0.00', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Total # of Periods:</label>
                                <?php echo $this->Form->input('duration_in_month', array('id'=>'duration_in_month', 'class' => 'select' ,'options'=>$months_opts, 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Interest Ratio Decimal Places:</label>
                                <?php echo $this->Form->input('interest_rate_decimal_places', array('div' => false, 'label' => false, 'id' => 'interest_rate_decimal_places', 'class' => 'select', 'default'=>'4' ,'options' => $decimal_places_opts)); ?>
                            </p>

                           <!-- <p class="button-height inline-label" id="interest_rate_decimal_place_txt">
                                <label class="label">Interest Rate Per Month:</label>
                                <span><b>.0000</b></span>
                            </p>
-->
                            <p class="button-height inline-label">
                                <label class="label">Discount % :</label>
                                <?php echo $this->Form->input('discount', array('type' => 'text','id'=>'discount', 'class' => 'input validate[required,custom[number]]' ,'value'=>'0.00', 'div' => false, 'label' => false,)); ?>
                                <?php echo $this->Form->input('tenor', array('type'=>'hidden','div' => false, 'label' => false, 'id'=>'tenor' ,'default'=>1)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Deposit Currency :</label>
                                <?php echo $this->Form->input('deposit_currency', array('div' => false, 'label' => false, 'id' => 'deposit_currency', 'class' => 'select', 'options' => $currency_opts)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Deposit:</label>
                                <?php echo $this->Form->input('original_deposit_amt', array('type' => 'text', 'div' => false, 'label' => false, 'id'=>'original_deposit_amt' ,'class' => 'input validate[required,custom[number]]', 'value'=>'0.00'));?>
                                <?php echo $this->Form->input('deposit', array('type' => 'hidden', 'div' => false, 'label' => false, 'id' => 'deposit', 'class' => '', 'value' => '0.00'));?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">USD Conversion Rate:</label>
                                <?php echo $this->Form->input('usd_rate', array('type' => 'text', 'div' => false, 'label' => false, 'id' => 'usd_rate', 'class' => 'input validate[required,custom[number]]', 'value' => '0.00'));  ?>
                            </p>

                            <p class="button-height inline-label" id="deposit_conversion_rate_txt">
                                <label class="label">Deposit USD:</label>
                                 <span><b>0.00</b></span>
                            </p>

                           <p class="button-height inline-label">
                                <label class="label">Payment Type:</label>
                                <?php echo $this->Form->input('payment_type', array('id'=>'payment_type', 'class' => 'select', 'div' => false, 'label' => false ,'options'=>$pay_type_opt)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Cheque No.:</label>
                                <?php echo $this->Form->input('cheque_no', array( 'div' => false, 'label' => false, 'id' => 'cheque_no', 'class' => 'input'));  ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Comments:</label>
                                <?php echo $this->Form->input('comments', array('id'=>'comments', 'class' => 'input full-width', 'div' => false, 'label' => false,)); ?>
                                <?php echo $this->Form->input('id', array('type'=>'hidden','div' => false, 'label' => false, 'id'=>'id')); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label for="save-btn" class="label">&nbsp;</label>
                                <button type="submit" class="button" id="save-btn">
                                    <span class="button-icon green-gradient"><span class="icon-download"></span></span>
                                    Save
                                </button>

                                <button type="button" class="button" id="cancel-btn">
                                    <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                                    Cancel
                                </button>
                            </p>
                        </fieldset>

                        <?php echo $this->Form->end();?>
                    </div>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- End main content -->

<!-- Side tabs shortcuts -->
<?php echo $this->element('side_tabs_shortcuts'); ?>
<!-- Sidebar/drop-down menu -->
<?php echo $this->element('right_side_infos'); ?>


<!-- Users URL -->
<input type="hidden" id="table-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'get')); ?>"/>
<input type="hidden" id="add-edit-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'add')); ?>"/>
<input type="hidden" id="load-sale-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'loadSale')); ?>"/>
<input type="hidden" id="delete-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'delete_')); ?>"/>
<input type="hidden" id="print-invoice-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'print_invoice')); ?>" />

<?php
echo $this->Html->script('setup.js');

/** Template functions **/
echo $this->Html->script('developr.input.js');
echo $this->Html->script('developr.message.js');
echo $this->Html->script('developr.modal.js');
echo $this->Html->script('developr.navigable.js');
echo $this->Html->script('developr.notify.js');
echo $this->Html->script('developr.scroll.js');
echo $this->Html->script('developr.progress-slider.js');
echo $this->Html->script('developr.tooltip.js');
echo $this->Html->script('developr.confirm.js');
echo $this->Html->script('developr.agenda.js');
echo $this->Html->script('developr.tabs.js');

echo $this->Html->script('libs/tinycon.min.js');
echo $this->Html->script('jquery.thfloat-0.3.min.js');
echo $this->Html->script('custom-scripts/edit_sales.js');
?>